#pragma once
#include "FilerFrogElement.h"

#define OPERATIONS_TOTAL 4320000

using namespace std;

/*
 * This class is used to perfom an operation on a given file.
 * The available operations are: Copy, Move, Delete, Rename.
 * In order to perform an operation do the following:
 * 	1. Instantiate a class that corresponds your desired operation with the appropriate information 
 * 	(as defined in the constructor).
 * 	2. Invoke "Execute()" method.
 * 
 * Example ("from" and "to" are of type LPCWSTR):
 * 		.
 * 		.
 * 		.
 * 		CopyFileOperation cfo(m_parent, from, to);
 * 		cfo.Execute();
 * 		.
 * 		.
 * 		.
 */
class FileOperation : FilerFrogElement{
private:
	WCHAR m_sourceFile[MAX_PATH];
	WCHAR m_destFile[MAX_PATH];

	list<wstring> m_moreFiles;

	bool m_ask;
	bool m_silent;
	bool m_allowundo;
protected:
	wstring m_type;

	bool ExecuteOperation(UINT func);

public:
	explicit
	FileOperation(HWND parent, LPCWSTR sourceFile, LPCWSTR destFile, DWORD sourceSize,
		bool ask, bool silent, bool allowundo=true);
	
	virtual bool Execute()=0;

	void AddFile(const wstring& filePath);
};

class CopyFileOperation : FileOperation{
public:
	explicit
	CopyFileOperation(HWND parent, LPCWSTR sourceFile, LPCWSTR destFile, bool ask, bool silent, DWORD sourceSize = 0);

	virtual bool Execute();
};

class MoveFileOperation : public FileOperation{
public:
	MoveFileOperation(HWND parent, LPCWSTR sourceFile, LPCWSTR destFile, bool ask, bool silent, DWORD sourceSize = 0);

	virtual bool Execute();
};

class DeleteFileOperation : FileOperation{
public:
	DeleteFileOperation(HWND parent, LPCWSTR file, bool ask, bool silent, bool allowundo, DWORD sourceSize = 0);

	virtual bool Execute();
};

class RenameFileOperation : FileOperation{
public:
	RenameFileOperation(HWND parent, LPCWSTR sourceFile, LPCWSTR destFile, bool ask, bool silent, DWORD sourceSize = 0);

	virtual bool Execute();
};